package ext.acae2.mail.util;

import java.util.Vector;

import wt.util.WTProperties;
import ext.acae2.mail.MailFile;

/**
 * @desription mail utility
 * @author cnie
 * @date 2013-3-6 下午3:24:21
 */
public class MailUtility {

	private static String mailHost = "";
	private static String mailFrom = "";
	static {
		try {
			WTProperties wtproperties = WTProperties.getLocalProperties();
			mailHost = wtproperties.getProperty("wt.mail.mailhost");
			mailFrom = wtproperties.getProperty("wt.mail.from");
		} catch (Throwable throwable) {
			throwable.printStackTrace(System.err);
			throw new ExceptionInInitializerError(throwable);
		}
	}

	public static boolean sendMail(Vector to, String subject, String content)
			throws Exception {
		boolean complete = false;
		try {
			MailFile mf = new MailFile();
			mf.setMailHost(mailHost);
			mf.setFrom(mailFrom);
			mf.setTo(to);
			mf.setSubject(subject);
			mf.setText(content);

			mf.send();
			complete = true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return complete;
	}

}
